package com.never.website.dao;

import java.util.List;

import org.springframework.jdbc.core.RowMapper;

public class DaoHelper<E> extends BaseDao{
	public int insertOrUpdate(String sql, Object[] parameters){
		getJdbcTemplate().update(sql, parameters);
		return getJdbcTemplate().queryForInt("SELECT last_insert_id()");
	}
	
	public void delete (String sql, Object[] parameters){
		getJdbcTemplate().update(sql, parameters);
	}
	
	public List<E> query (String sql, Object[] parameters, RowMapper<Object> rowMapper){
		List<E> resultList = null;
		if(parameters != null){
			resultList = (List<E>) getJdbcTemplate().query(sql, parameters, rowMapper);
		}else{
			resultList = (List<E>) getJdbcTemplate().query(sql, rowMapper);
		}
		return resultList;
	}
}
